mc.game.init = function(t){
	dbg("game loaded " + t);

	mc.game.load_start();
	$.when(
		mc.game.load_proto("leaders","units","items","task_types","tasks_common")
		//mc.game.load_proto("leaders"),
		//mc.game.load_proto("units"),
		//mc.game.load_proto("items"),
		//mc.game.load_proto("items"),
		//mc.game.load_proto("tasks_common")
	).then(function(){
		mc.game.load_end();
		mc.game.menu.draw(mc.extra_data);
	});
}

mc.game.calc_width = function(t){
	var list = t.find("> div");
	var iw = list.outerWidth(true);
	var ih = list.outerHeight(true);
	var cw = iw * list.length;
	t.width(cw);
	t.height(ih+16);
}
mc.game.calc_heigth = function(){
	var r = mc.cmd.get_right();
	var ri0 = mc.cmd.get_right_inner(0);
	var ri1 = mc.cmd.get_right_inner(1);
	return r.height() - (ri0.height() + ri1.height());
}
mc.game.sort_by_proto = function(a,b){
	return a.proto_id - b.proto_id;
}
mc.game.sort_by_entry = function(a,b){
	return a.entry - b.entry;
}
mc.game.load_start = function(){
	var o = $("#loader");
	var p = $("#main");
	var off = p.offset();
	o.show();
	o.width(p.width());
	o.height(p.height());
	o.offset({top:0,left:0});
	o.offset(off);
}
mc.game.load_end = function(){
	var o = $("#loader");
	o.offset({top:0,left:0});
	o.hide();
}
mc.game.delay_load = function(){
	mc.game.load_start();
	window.setTimeout(mc.game.load_end,2000);
}
